import request from '@/utils/request'

/**
 * 查询字典数据列表
 */
export function getDictDataList(query?: any) {
  return request.get('/system/dict/data/list', query)
}

/**
 * 查询字典数据详细
 */
export function getDictData(dictCode: number) {
  return request.get(`/system/dict/data/${dictCode}`)
}

/**
 * 根据字典类型查询字典数据信息
 */
export function getDictDataByType(dictType: string) {
  return request.get(`/system/dict/data/type/${dictType}`)
}

/**
 * 新增字典数据
 */
export function addDictData(data: any) {
  return request.post('/system/dict/data', data, {
    showLoading: true,
    showSuccess: true,
    successMsg: '字典数据新增成功',
  })
}

/**
 * 修改字典数据
 */
export function updateDictData(data: any) {
  return request.put('/system/dict/data', data, {
    showLoading: true,
    showSuccess: true,
    successMsg: '字典数据修改成功',
  })
}

/**
 * 删除字典数据
 */
export function delDictData(dictCode: number) {
  return request.delete(`/system/dict/data/${dictCode}`, {}, {
    showLoading: true,
    showSuccess: true,
    successMsg: '字典数据删除成功',
  })
}

/**
 * 导出字典数据
 */
export function exportDictData(query?: any) {
  return request.post('/system/dict/data/export', query, {
    responseType: 'blob',
    showLoading: true,
  })
}

